<template>
    <AuroraBackground :class="`${themeStore.theme} background`" style="width: 100%;">
      <div class="container">
        <header>
          <p class="title">我是Koala，很高兴见到你！</p>
          <p class="description">我可以帮你写代码、读文件、写作各种创意内容，请把你的任务交给我吧~</p>
        </header>
        <yd-textarea @keyup.enter="sendQuestion"  v-model="intent.content" style="width: 700px">
          <template v-slot:left>
            <t-button @click="chatStore.deepSeek = !chatStore.deepSeek" :theme="chatStore.deepSeek ? 'primary' : ''"  variant="outline">
              <template #icon>
                <SunnyIcon />
              </template>
              深度思考</t-button>
          </template>
          <template v-slot:right>
            <t-button style="margin-right: 10px" shape="circle" ghost theme="primary">
              <template #icon>
                <CloudUploadIcon />
              </template>
            </t-button>
            <t-button @click="sendQuestion" shape="circle">
              <template #icon>
                <SendIcon style="transform: rotateZ(-90deg)" />
              </template>
            </t-button>
          </template>
        </yd-textarea>
      </div>
    </AuroraBackground>

</template>

<script setup>
import ydTextarea from '@/components/common/textarea/index.vue'
import {CloudUploadIcon, SendIcon, SunnyIcon} from "tdesign-icons-vue-next";
import AuroraBackground from '@/components/inspia/AuroraBackground/index.vue'
import {useThemeStore} from "@/store/theme/index.js";
import {useChatStore} from "@/store/chat/index.js";
import {useSystemStore} from "@/store/system/index.js";
import {useRouter} from "vue-router";

const themeStore = useThemeStore();
const chatStore = useChatStore();
const systemStore = useSystemStore();
const router = useRouter();

// 用户意图
const intent = ref({
  content: "",
  role: 'user'
})

// 发送提问
const sendQuestion = () => {
  if (!intent.value.content) {
    systemStore.sendSystemNotification("请输入文本！" , "warning")
    return;
  }

  const chatId = chatStore.createChat(intent.value)

  router.push({
    name:'chat',
    params: {
      chatInfo: {
        question: intent.value.content,
        chatId: chatId
      }
    }
  })

}

</script>


<style scoped>
.background {
  width: 100%;
}
.container {
  font-size: 14px;
  display: flex;
  flex-direction: column;
  z-index: 1;
  width: 100%;
  align-items: center;
  color: var(--color);
}
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.title {
  font-size: 24px;
}
.description {
  margin-top: 20px;
}

</style>
